package com.baizhi.abstractx2;

import java.util.Scanner;

import static java.lang.System.out;

/**
 * 三角形
 */
public class Triangle extends Shape {
    private double bottom;
    private double height;
    private double left; //腰
    private double right; //腰


    @Override
    public double area() {
        return bottom * height / 2;
    }

    @Override
    public double perimeter() {
        return bottom + left + right;
    }

    @Override
    public void inInfo(Scanner scan) {
        out.println("请输入三角形的底边");
        bottom = scan.nextDouble();
        out.println("请输入三角形的高：");
        height = scan.nextDouble();
        out.println("请输入三角形的第二条边：");
        left = scan.nextDouble();
        out.println("请输入三角形的第三条边：");
        right = scan.nextDouble();

        //打印图形的面积和周长
        out.println("您输入的长方形的面积是：" + area());
        out.println("您输入的长方形的周长是：" + perimeter());
    }
}
